package com.dk.em;

import java.io.Serializable;

public class Result<T> implements Serializable {
    private String code;
    private String message;
    private T data;

    //    自定义通用方法
    public static Result ZHRESPONSE(ResultEnum resultEnum) {
        return new Result(resultEnum.getCode(), resultEnum.getMessage());
    }

//    通用ok
    public static Result OK(){
        return new Result(ResultEnum.OK.getCode(),ResultEnum.OK.getMessage());
    }

//    通用失败
    public static Result ERROR(){
        return new Result(ResultEnum.ERROR.getCode(),ResultEnum.ERROR.getMessage());
    }

        public Result() {//远程调用的实体需要系列化
    }

    public Result(String code, String message) {
        this.code = code;
        this.message = message;
        this.data = data;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public T getData() {
        return data;
    }

    public Result setData(T data) {
        this.data = data;
        return this;
    }
}
